<? if (!$form_model->deleted_at): ?>
	<div class="toolbar">
		<a class="imageLink new_message img_noBottomPading" href="<?= url('shop/customer_notifications/create/'.$form_model->id.'?'.uniqid()) ?>">New message</a>

		<a class="imageLink new_from_template img_noBottomPading" href="#" onclick="new PopupForm('preview_onLoadMessageTemplateForm'); return false">New from template</a>
		<div class="clear"></div>
	</div>
<? endif ?>

<table class="simpleList">
	<thead>
		<tr>
			<th class="iconCell"></th>
			<th>Subject</th>
			<th>Email</th>
			<th>Sender</th>
			<th class="date last">Date and Time</th>
		</tr>
	</thead>
	<tbody>
		<?
			foreach ($form_model->customer_notifications as $record):
				$preview_url = url('shop/customer_notifications/view/'.$record->id.'/'.$form_model->id);
		?>
		<tr class="<?= Backend_Html::zebra('order_customer_notifications') ?> <?= $record->is_system ? null : 'important' ?>" title="<?= $record->is_system ? 'Internal system notification' : 'Customer notification' ?>">
			<td class="iconCell <?= $record->is_system ? 'system_message' : 'message' ?>"></td>
			<td <?= click_link($preview_url) ?> class="link"><a href="<?= $preview_url  ?>"><?= h($record->subject) ?></a></td>
			<td <?= click_link($preview_url) ?> class="link"><a href="<?= $preview_url  ?>"><?= h($record->email) ?></a></td>
			<td <?= click_link($preview_url) ?> class="link"><a href="<?= $preview_url  ?>"><?= h($record->displayField('created_user_name')) ?></a></td>
			<td <?= click_link($preview_url) ?> class="link date last"><a href="<?= $preview_url  ?>"><?= $record->displayField('created_at') ?></a></td>
		</tr>
		<? endforeach;?>
		<? if (!$form_model->customer_notifications->count): ?>
			<tr class="noData">
				<td colspan="5">No notifications found</td>
			</tr>
		<? endif ?>
	</tbody>
</table>